package org.jivesoftware.smackx.pubsub.provider;

import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.pubsub.packet.PubSub;
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
import org.xmlpull.v1.XmlPullParser;

public class PubSubProvider
  implements IQProvider
{
  public IQ parseIQ(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    PubSub localPubSub = new PubSub();
    String str = paramXmlPullParser.getNamespace();
    localPubSub.setPubSubNamespace(PubSubNamespace.valueOfFromXmlns(str));
    int i = 0;
    while (true)
    {
      int j;
      label74: 
      do
        while (true)
        {
          PacketExtension localPacketExtension;
          do
          {
            if (i != 0)
              return localPubSub;
            j = paramXmlPullParser.next();
            if (j != 2)
              break label74;
            localPacketExtension = PacketParserUtils.parsePacketExtension(paramXmlPullParser.getName(), str, paramXmlPullParser);
          }
          while (localPacketExtension == null);
          localPubSub.addExtension(localPacketExtension);
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("pubsub"))));
      i = 1;
    }
  }
}